import HTTP from '@/libs/http'

class InitApi extends HTTP {
  /**
   * @description: 获取Tab
   * @author lsr
   * @date 2021.03.09
   */
  tab() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/all_event/tab'
    })
  }

  /**
   * @description: 获取事件类型
   * @author lsr
   * @date 2021.03.09
   */
  eventType() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/all_event/event_manage'
    })
  }

  /**
   * @description: 事件统计
   * @author lsr
   * @date 2021.03.29
   */
  count() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/all_event/count_event'
    })
  }
}

class ManageApi extends HTTP {
  /**
   * @description: 获取事件列表
   * @author lsr
   * @date 2021.03.09
   * @param {String} eventStatus 事件状态
   * @param {String} eventDescription 根据事件标题和内容搜索
   * @param {Int} recordSize 开始下标（第一条数据的下标为0）
   * @param {Int} pageSize 每页显示条数
   */
  list({ eventStatus, eventDescription, recordSize, pageSize }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/all_event/list',
      params: {
        eventStatus,
        eventDescription,
        recordSize,
        pageSize
      }
    })
  }

  /**
   * @description: 添加
   * @author: lsr
   * @date: 2020.01.26
   * @param {String} eventName  // 事件标题
   * @param {String} eventType // 事件分类
   * @param {String} eventScale // 事件规模
   * @param {String} eventLocation // 事件点位
   * @param {String} communityRegion // 所属区域
   * @param {String} eventDescription // 事件描述
   * @param {String} ImageUrl // 图片、视频
   * @param {String} isExposure // 是否公开
   * @param {String} isDisposal // 是否可自行处理
   * @param {String} reportRegionCode // 上报人所在社区编码
   * @param {String} longitude // 经度
   * @param {String} latitude // 维度
   */
  save({
    eventName,
    eventType,
    eventScale,
    eventLocation,
    communityRegion,
    eventDescription,
    firstImageUrl,
    secondImageUrl,
    thirdImageUrl,
    fourthImageUrl,
    fifthImageUrl,
    sixthImageUrl,
    seventhImageUrl,
    eighthImageUrl,
    ninthImageUrl,
    isExposure,
    isDisposal,
    reportRegionCode,
    reportPerson,
    eventOrigin,
    longitude,
    latitude
  }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-activiti/all_event/save',
      data: {
        eventName,
        eventType,
        eventScale,
        eventLocation,
        communityRegion,
        eventDescription,
        firstImageUrl,
        secondImageUrl,
        thirdImageUrl,
        fourthImageUrl,
        fifthImageUrl,
        sixthImageUrl,
        seventhImageUrl,
        eighthImageUrl,
        ninthImageUrl,
        isExposure,
        isDisposal,
        reportRegionCode,
        reportPerson,
        eventOrigin,
        longitude,
        latitude
      }
    })
  }

  /**
   * @description: 获取事件详情
   * @author lsr
   * @date 2021.03.09
   * @param {String} eventCode 事件编码
   */
  detail({ eventCode }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/all_event/detail',
      params: {
        eventCode
      }
    })
  }

  /**
   * @description: 1：上报/处置完成  2：开始处置  3：退回
   * @author: lsr
   * @date: 2021.03.11
   * @param {String} acceptance 流程走向
   * @param {String} eventCode 事件标识
   * @param {String} nextPerson 下一个责任人
   * @param {String} comment 备注
   * @param {String} eventOrigin 事件来源
   * @param {String} assignee 当前责任人
   */
  updateStatus({ eventCode, nextPerson, eventOrigin, comment, acceptance, assignee }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-activiti/all_event/finish',
      data: {
        eventCode,
        nextPerson,
        eventOrigin,
        comment,
        acceptance,
        assignee
      }
    })
  }

  /**
   * @description: 延时申请
   * @author: lsr
   * @date: 2021.06.24
   * @param {String} eventCode 事件编码
   * @param {String} deptCode 部门
   * @param {String} delayedEndTime 申请时间
   * @param {String} recordType 记录类型：3延时
   * @param {String} visitRecord 申请原因
   */
  delayApply({ eventCode, deptCode, delayedEndTime, recordType, visitRecord }) {
    return this.request({
      method: 'PUT',
      url: '/smart/smart-activiti/all_event/overTimeApply',
      data: {
        eventCode,
        deptCode,
        delayedEndTime,
        recordType,
        visitRecord
      }
    })
  }

  /**
   * @description: 督办回复
   * @author: lsr
   * @date: 2021.06.24
   * @param {String} eventCode 事件编码
   * @param {String} visitRecord 记录内容
   * @param {String} button 操作标识
   */
  superviseReply({ eventCode, visitRecord, button }) {
    return this.request({
      method: 'PUT',
      url: '/smart/smart-activiti/all_event/supervise',
      data: {
        eventCode,
        visitRecord,
        button
      }
    })
  }

  /**
   * @description: 督办详情
   * @author: lsr
   * @date: 2021.06.24
   * @param {String} eventCode 事件编码
   */
  superviseDetail({ eventCode }) {
    return this.request({
      method: 'get',
      url: '/smart/smart-activiti/all_event/superviseDetail',
      params: {
        eventCode
      }
    })
  }

  /**
   * @description: 延时申请详情
   * @author: lsr
   * @date: 2021.06.28
   * @param {String} eventCode 事件编码
   */
  overTimeDetail({ eventCode }) {
    return this.request({
      method: 'get',
      url: '/smart/smart-activiti/all_event/overTimeDetail',
      params: {
        eventCode
      }
    })
  }

  /**
   * @description: 处置结果详情
   * @author: lsr
   * @date: 2021.09.23
   * @param {String} eventCode 事件编码
   * @param {String} appCode 事件编码
   */
  resultDetail({ eventCode, appCode }) {
    return this.request({
      method: 'get',
      url: '/smart/smart-app/all_event/record',
      params: {
        eventCode,
        appCode
      }
    })
  }
}

class Static extends HTTP {
  /**
   * @description: 获取事件统计
   * @author llx
   * @date 2021.03.09
   */
  eventCount() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-government-statistic/app/event/statistic/eventCount'
    })
  }

  /**
   * @description: 获取上报事件统计
   * @author llx
   * @date 2021.03.09
   * @param {Int} timeParam 时间
   */
  report({ timeParam }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-government-statistic/app/event/statistic/report',
      params: { timeParam }
    })
  }

  /**
   * @description: 获取事件办结统计
   * @author llx
   * @date 2021.03.09
   * @param {Int} timeParam 时间
   */
  finish({ timeParam }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-government-statistic/app/event/statistic/finish',
      params: { timeParam }
    })
  }

  /**
   * @description: 获取事件处置时长统计
   * @author llx
   * @date 2021.03.09
   * @param {Int} timeParam 时间
   */
  completionTime({ timeParam }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-government-statistic/app/event/statistic/completionTime',
      params: { timeParam }
    })
  }
}

class EventClass {
  constructor() {
    this.Init = new InitApi()
    this.Manage = new ManageApi()
    this.Static = new Static()
  }
}

const Event = new EventClass()

export default Event
